#include <iostream>
#include <vector>
#include <vector>
#include <cstdlib>
using namespace std;

struct stu {
    string name;
    string gender;
    int age{};
};


void welcome(){
    cout << "----------名片管理系统---------" << endl;
    cout << "1,新增信息" << endl;
    cout << "2,显示所有" << endl;
    cout << "3,查询学生" << endl;
    cout << "4,删除数据" << endl;
    cout << "5,退出系统" << endl;
}

void showall(vector<stu> &msg){
    auto count = msg.size();
    for (int i = 0; i < count; i++) {
        cout << msg[i].name<<endl;
        cout << msg[i].gender<<endl;
        cout << msg[i].age<<endl;
    }
}

void add(vector<stu> &msg) {
    stu s;
    cout << "学生姓名:";
    cin >> s.name;
    cout << "学生性别:";
    cin >> s.gender;
    cout << "学生年龄:";
    cin >> s.age;
    msg.push_back(s);

}

void query(vector<stu> &msg) {
    cout << "要查询的名字是：";

    string name;
    cin >> name;
    auto count = msg.size();
    for (int i = 0; i < count; i++) {
        if (msg[i].name == name) {
            cout << msg[i].name << endl;
            cout << msg[i].gender << endl;
            cout << msg[i].age << endl;
        }
    }
}

void del(vector<stu> &msg) {
    cout << "要删除的名字是：";
    string name;
    cin >> name;
    for (auto i = msg.begin(); i < msg.end(); i++) {
        if (i->name == name) {
            msg.erase(i);
            break;
        }
    }
}

void quit(){
    exit(0);
}

void choose(vector<stu> &msg) {
    cout << "请输入你想选择的选项：";
    int x = 0;
    cin >> x;
    switch (x) {
        case 1:
            add(msg);
            break;
        case 2:
            showall(msg);
            break;
        case 3:
            query(msg);
            break;
        case 4:
            del(msg);
            break;
        case 5:
            quit();
            break;
        default:
            break;
    }
}

int main() {
    vector<stu> msg;
    while (1) {
        int count = 0;
        count++;
        welcome();
        choose(msg);
        if (count > 100)
            break;
    }
}

